package soma.rest.resource;

import java.util.Date;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import soma.rest.model.Mentee;

@Path("mentee")

@Component
@Scope("singleton")
public class MenteeResourceImpl {

	@GET
	@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
	public Mentee getMentees(){
		Mentee mentee = new Mentee();
		mentee.setBirth(new Date());
		mentee.setId(1);
		mentee.setName("kkkk");
		//mentee.getMentee().setId(2);
		
		return mentee;
	}

	@GET
	@Path("input")
	@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
	public Mentee returnMentee(){
		Mentee mentee = new Mentee();
		mentee.setBirth(new Date());
		mentee.setId(1);
		mentee.setName("주리");
		
		return mentee;
		
	}
	
	@POST
	@Path("input")
	@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
	@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
	public Mentee changeMentee(Mentee mentee){
		
		mentee.setName(mentee.getId()+mentee.getName());
		
		return mentee;
		
	}
	
	@POST
	@Path("input2")
	@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
	@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
	public Mentee returnMentee2(Mentee mentee, @HeaderParam("key") String header, 
			@QueryParam("test") String query){
		
		System.out.println("heder key:"+header);
		System.out.println("query :"+query);
		return mentee;
		
	}

	
	
}
